<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0,minimum-scale=1.0, user-scalable=no">
    <title>{:lang('Login')}</title>
    <script src="__STATIC__/hybit/js/rem.js"></script>
    <link rel="stylesheet" href="__STATIC__/hybit/css/myCommon.css">
    <if cookie('think_var') == 'en-us'>
        <link rel="stylesheet" href="__STATIC__/hybit/css/style_en.css">
    <else/>
        <link rel="stylesheet" href="__STATIC__/hybit/css/style.css">
    </if>
</head>
<body style="min-height: calc(100vh - 0.8rem);background: #1f1e24;">
    <div class="head">
       <a href="javascript:history.back(-1)"><img src="__STATIC__/hybit/images/headleft.png" alt=""></a>
       <p>{:lang('Login')}</p>
    </div>
    <h3 class="mytitle" style="margin-top: 0.8rem;">{:lang('Login')}</h3>
    <form action="" method="post" class="layui-form">
        <div class="loginbg">
            <input type="text" class="inputshow" name="username" placeholder="{:lang('Your Email or Phone Number')}">
            <input type="password" class="inputshow" name="password" placeholder="{:lang('Password')}">
            <!--<div class="inputshow1">-->
            <!--    <input type="text" name="code" placeholder="{:lang('Please enter code')}">-->
            <!--    <button type="button" class="yanzheng">{:lang('Get code')}</button>-->
            <!--</div>-->
            <button type="button" class="loginbtn" lay-submit>{:lang('Login')}</button>
            <div class="forgeta">
                <a href="{:url('user/login/findPassword')}">{:lang('Forgot password')}</a>
            </div>
            <a href="{:url('user/register/index')}" class="goregister">{:lang('Sign up')}</a>
        </div>
    </form>
</body>
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript">
layui.use(['form','layer'],function(){
    var layer = layui.layer,
        form = layui.form;

    $('.yanzheng').click(function(){
        var username = $('input[name=username]').val();
        var obj = $(this);
        $(obj).attr('disabled', true);
        $.ajax({
            type: 'get',
            url: '{:url("user/VerificationCode/send")}',
            data: {username:username,act:1},
            success:function(res){
                layer.msg(res.msg)
                if(res.code == 1){
                    let count = 60;
                    const countDown = setInterval(() => {
                    if (count === 0) {
                    $(obj).text('{:lang("Resend")}').removeAttr('disabled');
                    clearInterval(countDown);
                    } else {
                       $(obj).text(count + 's');
                    }
                    count--;
                    }, 1000);
                }else{
                    $(obj).text('{:lang("Resend")}').removeAttr('disabled');
                }
            }
        });
    });

    //监听提交
    form.on('submit', function(data){
        var _this = $(this);
        _this.attr("disabled",true);
        $.ajax({
            type: 'post',
            url: '{:url("user/Login/doLogin")}',
            data: data.field,
            success:function(res){
                layer.msg(res.msg)
                if(res.code == 1){
                    setTimeout(function(){ location.reload(); }, 1500);
                }else{
                    _this.removeAttr("disabled");
                }
            }
        });
        return false;
    });
});
</script>
</html>